-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watcher reporting: add email warning if CSV attachment contains values that may be interperted as formulas #44460
Watcher reporting: add email warning if CSV attachment contains values that may be interperted as formulas #44460
Conversation
@@ -44,7 +44,7 @@ dependencies { | |||
|
|||
testCompile 'org.subethamail:subethasmtp:3.1.7' | |||
// needed for subethasmtp, has @GuardedBy annotation | |||
testCompile 'com.google.code.findbugs:jsr305:3.0.1' | |||
testCompile 'com.google.code.findbugs:jsr305:3.0.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to avoid JAR hell when running tests via IntelliJ (nothing specific to the changes here)
Pinging @elastic/es-core-features |
LGTM! |
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized, that despite the current documenation, body is not actually required, will need to adjust this to always emit a warning even if the body is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 0acff82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super small nits. great stuff. LGTM.
|
||
import static javax.mail.Part.ATTACHMENT; | ||
import static javax.mail.Part.INLINE; | ||
|
||
public abstract class Attachment extends BodyPartSource { | ||
|
||
private final boolean inline; | ||
private final Set<String> warnings; | ||
|
||
protected Attachment(String id, String name, String contentType, boolean inline) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this constructor used anymore? Im ok w/ removing it if we dont use it anywhere. Also, if we dont want a NPE down in the EmailTemplate
we should check for null assignment in the other constructor, maybe with a Objects.requireNonNull
. Otherwise the user is free to put null there and receive a nice NPE during warnings.addAll(attachment.getWarnings());
below. Ill add a note with here is the NPE im talking about
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this constructor is still used in some cases.
I added an assert warnings != null
, since this is an internal API, the variable is final, means that someone working on Watcher internals would be required to explicitly call the second constructor with null
, I think the assert is sufficient to express "don't do that". ed5128f
if (attachments != null) { | ||
for (Attachment attachment : attachments.values()) { | ||
builder.attach(attachment); | ||
warnings.addAll(attachment.getWarnings()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the NPE im talking about
...org/elasticsearch/xpack/watcher/notification/email/attachment/ReportingAttachmentParser.java
Outdated
Show resolved
Hide resolved
...her/src/test/java/org/elasticsearch/xpack/watcher/notification/email/EmailTemplateTests.java
Outdated
Show resolved
Hide resolved
…c#44460) This commit introduces a Warning message to the emails generated by Watcher's reporting action. This change complements Kibana's CSV formula notifications (see elastic/kibana#37930). This is implemented by reading a header (kbn-csv-contains-formulas) provided by Kibana to notify to attach the Warning to the email. The wording of the warning is borrowed from Kibana's UI and may be overridden by a dynamic setting xpack.notification.reporting.warning.kbn-csv-contains-formulas.text. This warning is enabled by default, but may be disabled via a dynamic setting xpack.notification.reporting.warning.enabled.
#45557) * Watcher add email warning if CSV attachment contains formulas (#44460) This commit introduces a Warning message to the emails generated by Watcher's reporting action. This change complements Kibana's CSV formula notifications (see elastic/kibana#37930). This is implemented by reading a header (kbn-csv-contains-formulas) provided by Kibana to notify to attach the Warning to the email. The wording of the warning is borrowed from Kibana's UI and may be overridden by a dynamic setting xpack.notification.reporting.warning.kbn-csv-contains-formulas.text. This warning is enabled by default, but may be disabled via a dynamic setting xpack.notification.reporting.warning.enabled.
This commit introduces a Warning message to the emails generated by Watcher's reporting action. This change complements Kibana's CSV formula notifications (see elastic/kibana#37930). This is implemented by reading a header (kbn-csv-contains-formulas) provided by Kibana to notify to attach the Warning to the email. The wording of the warning is borrowed from Kibana's UI and may be overridden by a dynamic setting (
xpack.notification.reporting.warning.kbn-csv-contains-formulas.text
). This warning is enabled by default, but may be disabled via a dynamic settingxpack.notification.reporting.warning.enabled
.Note - the doc PR will need to be separate since the majority of this is documented included from the Kibana docs.
Kibana
Watcher email - HTML
Watcher email - Text